<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>试卷管理</title>
    <#-- 使用相对当前模板文件的路径 再去找另一个模板文件 -->
    <#include "/common/link.ftl">

</head>
<body class="hold-transition skin-black sidebar-mini">
<div class="wrapper">
    <#include "/common/navbar.ftl">
    <!--定义一个变量  用于菜单回显-->
    <#assign currentMenu="exam"/>

    <#include "/common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>试卷管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/exam/list" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <#if EMPLOYEE_IN_SESSION.admin>
                    <a href="/exam/input" class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                    </#if>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive ">
                    <table class="table table-hover table-bordered table-striped">
                        <thead>
                        <tr>
                            <th>编号</th>
                            <th>试卷标题</th>
                            <th>考试时长</th>
                            <th>试卷总分</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#list pageInfo.list as e>
                            <tr>
                                <td>${e.id}</td>
                                <td>${e.title}</td>
                                <td>${e.examMinute}</td>
                                <td>${e.totalScore}</td>
                                <td>
                                    <a href="#" data-id="${e.id}" class="btn btn-primary btn-xs btn-answer" >
                                        <span class="glyphicon glyphicon-phone-alt"></span> 答题</a>
                                    <#if EMPLOYEE_IN_SESSION.admin>
                                    <a href="/exam/show?id=${e.id}" class="btn btn-success btn-xs btn-show" >
                                        <span class="glyphicon glyphicon-phone-alt"></span> 查看</a>
                                    <a class="btn btn-danger btn-xs btn-delete" data-url="/exam/delete?id=${e.id}">
                                        <span class="glyphicon glyphicon-trash"></span> 删除</a>
                                    </#if>
                                </td>
                            </tr>
                        </#list>
                        </tbody>
                    </table>
                    <!--分页-->
                    <#include "/common/page.ftl" >
                </div>
            </div>
        </section>
    </div>
    <#include "/common/footer.ftl" >
</div>
<script>
    $(function () {
        $(".btn-answer").click(function () {
            var id = $(this).data("id");
            Swal.fire({
                title: '确定开始答题吗?',
                icon: 'warning',
                showCancelButton: true,
                confirmButtonText: '确定',
                cancelButtonText: '取消'
            }).then((result) => {
                if (result.value) {
                    window.location.href = "/exam/answer?id=" + id;
                }
            });
        });
    });
</script>
</body>
</html>
